package com.hooda.business;

import com.hooda.server.Request;
import com.hooda.server.Response;
import com.hooda.servlet.HttpServlet;
import com.hooda.utils.HttpProtocolUtil;

import java.io.IOException;

/**
 * @author zhangzp
 * @version 1.0, 2021/10/11
 */
public class DemoServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>DemoServlet get</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>DemoServlet post</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
